Skip to content

perf(propagation): tighten tracestate, baggage, and tag inject paths#8234

Merged
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-01-pr8188-3-perf-propagation-dsm
May 5, 2026
Merged

perf(propagation): tighten tracestate, baggage, and tag inject paths#8234
BridgeAR merged 2 commits into
masterfrom
BridgeAR/2026-05-01-pr8188-3-perf-propagation-dsm

Conversation

@BridgeAR
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR commented May 1, 2026

W3C tracestate parse, baggage extract, and _dd.p.* tag inject all
run on every traced HTTP request. Several sub-allocations and one
quadratic parse loop are dropped.

tracestate.js#fromString walked value.matchAll(regex) and
inserted each match at the front of the result with Array#unshift,
which is O(n) per call. push plus a single reverse() gives the
same final order in O(n); the Map then iterates oldest-first so
toString's prepend builds the W3C-spec newest-first wire form.
forVendor reuses the state.toString() value computed one line
above instead of recomputing it.

text_map.js swaps three replaceAll(/[\xNN]/g, ...) regex
literals matching a single character for replaceAll('=', '~') /
replaceAll('~', '='), which skip the regex match path. The
m-flag on the extract regex was always dead (no anchors in the
pattern). _injectTraceparent walks trace.tags via
Object.keys(...) instead of banned for-in; the trace-tags
object's prototype chain isn't ours to trust, and for-in
enumerates inherited keys. _injectBaggageItems swaps
Object.entries for Object.keys + indexed read, dropping the
per-baggage-item [k, v] tuple. _extractBaggageItems caches the
baggageTagKeys Set on the propagator (rebuilt only when the
config array reference changes, e.g. remote-config rotation) and
gates decodeURIComponent behind value.includes('%') — a
microbenchmark pins the gated path at 13.4x faster than running
decodeURIComponent on plain ASCII baggage and only 2% slower than
the raw call on percent-encoded values.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.64%. Comparing base (4db54b1) to head (00d0ec6).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8234      +/-   ##
==========================================
+ Coverage   89.18%   89.64%   +0.45%     
==========================================
  Files         832      832              
  Lines       43754    43776      +22     
  Branches     8049     8052       +3     
==========================================
+ Hits        39022    39241     +219     
+ Misses       4732     4535     -197     
Flag Coverage Δ
aiguard-integration-active 40.89% <37.93%> (-0.02%) ⬇️
aiguard-integration-latest 40.84% <37.93%> (-0.02%) ⬇️
aiguard-integration-maintenance 40.89% <37.93%> (-0.02%) ⬇️
aiguard-macos 35.41% <8.00%> (-0.14%) ⬇️
aiguard-ubuntu 35.52% <8.00%> (-0.14%) ⬇️
aiguard-windows 35.32% <8.00%> (-0.14%) ⬇️
apm-capabilities-tracing-macos 48.52% <100.00%> (+0.03%) ⬆️
apm-capabilities-tracing-ubuntu-active 48.55% <100.00%> (+0.05%) ⬆️
apm-capabilities-tracing-ubuntu-latest 48.52% <100.00%> (+0.04%) ⬆️
apm-capabilities-tracing-ubuntu-maintenance 48.54% <100.00%> (+0.03%) ⬆️
apm-capabilities-tracing-ubuntu-oldest 48.54% <100.00%> (+0.04%) ⬆️
apm-capabilities-tracing-windows 48.35% <100.00%> (+0.08%) ⬆️
apm-integrations-aerospike-18-gte.5.2.0 34.60% <8.00%> (-0.14%) ⬇️
apm-integrations-aerospike-20-gte.5.5.0 34.62% <8.00%> (-0.14%) ⬇️
apm-integrations-aerospike-22-gte.5.12.1 34.62% <8.00%> (-0.14%) ⬇️
apm-integrations-aerospike-22-gte.6.0.0 34.62% <8.00%> (-0.14%) ⬇️
apm-integrations-aerospike-eol- 34.52% <8.00%> (-0.14%) ⬇️
apm-integrations-child-process 35.76% <8.00%> (-0.15%) ⬇️
apm-integrations-confluentinc-kafka-javascript-18 41.55% <74.66%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-20 41.57% <74.66%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-22 41.57% <74.66%> (-0.08%) ⬇️
apm-integrations-confluentinc-kafka-javascript-24 41.50% <74.66%> (-0.08%) ⬇️
apm-integrations-couchbase-18 34.80% <8.00%> (+0.01%) ⬆️
apm-integrations-couchbase-eol 34.88% <8.00%> (-0.14%) ⬇️
apm-integrations-dns 34.62% <8.00%> (-0.14%) ⬇️
apm-integrations-elasticsearch 35.22% <8.00%> (-0.13%) ⬇️
apm-integrations-http-latest 42.54% <24.00%> (-0.12%) ⬇️
apm-integrations-http-maintenance 42.60% <24.00%> (-0.12%) ⬇️
apm-integrations-http-oldest 42.61% <24.00%> (-0.12%) ⬇️
apm-integrations-http2 40.04% <24.00%> (-0.13%) ⬇️
apm-integrations-kafkajs-latest 41.44% <74.66%> (-0.08%) ⬇️
apm-integrations-kafkajs-oldest 41.50% <74.66%> (-0.08%) ⬇️
apm-integrations-net 35.28% <8.00%> (-0.14%) ⬇️
apm-integrations-next-11.1.4 29.49% <8.00%> (-0.12%) ⬇️
apm-integrations-next-13.2.0 31.00% <8.00%> (-0.13%) ⬇️
apm-integrations-next-gte.10.2.0.and.lt.11 23.33% <ø> (ø)
apm-integrations-next-gte.11.0.0.and.lt.13 31.00% <8.00%> (-0.13%) ⬇️
apm-integrations-next-gte.13.0.0.and.lt.14 31.25% <8.00%> (-0.13%) ⬇️
apm-integrations-next-gte.14.0.0.and.lte.14.2.6 31.07% <8.00%> (-0.15%) ⬇️
apm-integrations-next-gte.14.2.7.and.lt.15 31.07% <8.00%> (-0.13%) ⬇️
apm-integrations-next-gte.15.0.0 31.13% <8.00%> (-0.13%) ⬇️
apm-integrations-oracledb 34.89% <8.00%> (-0.13%) ⬇️
apm-integrations-prisma-18-gte.6.16.0.and.lt.7.0.0 35.19% <8.00%> (-0.13%) ⬇️
apm-integrations-prisma-latest-all 35.51% <8.00%> (-0.13%) ⬇️
apm-integrations-restify 36.83% <8.00%> (-0.07%) ⬇️
apm-integrations-sharedb 34.21% <8.00%> (-0.14%) ⬇️
apm-integrations-tedious 34.78% <8.00%> (-0.14%) ⬇️
appsec-express 52.38% <24.00%> (-0.12%) ⬇️
appsec-fastify 48.97% <24.00%> (-0.11%) ⬇️
appsec-graphql 49.23% <24.00%> (+<0.01%) ⬆️
appsec-integration-active 37.39% <0.00%> (-0.02%) ⬇️
appsec-integration-latest 37.36% <0.00%> (-0.02%) ⬇️
appsec-integration-maintenance 37.38% <0.00%> (-0.02%) ⬇️
appsec-integration-oldest 37.38% <0.00%> (-0.02%) ⬇️
appsec-kafka 41.80% <24.00%> (-0.12%) ⬇️
appsec-ldapjs 40.93% <8.00%> (-0.13%) ⬇️
appsec-lodash 41.04% <8.00%> (-0.13%) ⬇️
appsec-macos 56.45% <24.00%> (-0.12%) ⬇️
appsec-mongodb-core 45.32% <24.00%> (-0.11%) ⬇️
appsec-mongoose 46.20% <24.00%> (-0.11%) ⬇️
appsec-mysql 48.39% <24.00%> (-0.11%) ⬇️
appsec-next-latest-11.1.4 29.67% <8.00%> (-0.12%) ⬇️
appsec-next-latest-13.2.0 31.20% <8.00%> (-0.13%) ⬇️
appsec-next-latest-gte.10.2.0.and.lt.11 28.55% <ø> (ø)
appsec-next-latest-gte.11.0.0.and.lt.13 31.18% <8.00%> (-0.13%) ⬇️
appsec-next-latest-gte.13.0.0.and.lt.14 31.38% <8.00%> (-0.13%) ⬇️
appsec-next-latest-gte.14.0.0.and.lte.14.2.6 31.22% <8.00%> (-0.13%) ⬇️
appsec-next-latest-gte.14.2.7.and.lt.15 31.22% <8.00%> (-0.13%) ⬇️
appsec-next-latest-gte.15.0.0 31.22% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-11.1.4 29.68% <8.00%> (-0.12%) ⬇️
appsec-next-oldest-13.2.0 31.43% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-gte.10.2.0.and.lt.11 28.68% <ø> (ø)
appsec-next-oldest-gte.11.0.0.and.lt.13 31.20% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-gte.13.0.0.and.lt.14 31.63% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-gte.14.0.0.and.lte.14.2.6 31.47% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-gte.14.2.7.and.lt.15 31.47% <8.00%> (-0.13%) ⬇️
appsec-next-oldest-gte.15.0.0 31.47% <8.00%> (-0.13%) ⬇️
appsec-node-serialize 40.24% <8.00%> (-0.13%) ⬇️
appsec-passport 44.17% <24.00%> (-0.12%) ⬇️
appsec-postgres 47.98% <24.00%> (-0.13%) ⬇️
appsec-sourcing 39.82% <24.00%> (-0.11%) ⬇️
appsec-stripe 41.88% <8.00%> (-0.13%) ⬇️
appsec-template 40.40% <8.00%> (-0.13%) ⬇️
appsec-ubuntu 56.53% <24.00%> (-0.12%) ⬇️
appsec-windows 56.35% <24.00%> (-0.10%) ⬇️
debugger-ubuntu-active 43.99% <0.00%> (-0.10%) ⬇️
debugger-ubuntu-latest 43.94% <0.00%> (-0.10%) ⬇️
debugger-ubuntu-maintenance 44.00% <0.00%> (-0.10%) ⬇️
debugger-ubuntu-oldest 44.36% <0.00%> (-0.10%) ⬇️
instrumentations-instrumentation-bluebird 29.58% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-body-parser 37.31% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-child_process 35.15% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-cookie-parser 31.46% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-express 31.67% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 31.57% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-express-session 36.99% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-fs 29.27% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-generic-pool 30.22% <ø> (ø)
instrumentations-instrumentation-http 36.62% <22.66%> (-0.12%) ⬇️
instrumentations-instrumentation-knex 29.56% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-light-my-request 36.92% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-mongoose 30.64% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-multer 37.09% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-mysql2 35.12% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-passport 40.71% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-passport-http 40.50% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-passport-local 41.00% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-pg 34.66% <8.00%> (-0.14%) ⬇️
instrumentations-instrumentation-promise 29.52% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-promise-js 29.53% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-q 29.56% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-url 29.52% <8.00%> (-0.13%) ⬇️
instrumentations-instrumentation-when 29.54% <8.00%> (-0.13%) ⬇️
instrumentations-integration-esbuild-active 19.54% <0.00%> (-0.02%) ⬇️
instrumentations-integration-esbuild-latest 19.53% <0.00%> (-0.02%) ⬇️
instrumentations-integration-esbuild-maintenance 19.54% <0.00%> (-0.02%) ⬇️
instrumentations-integration-esbuild-oldest 19.53% <0.00%> (-0.02%) ⬇️
llmobs-ai 38.09% <8.00%> (-0.14%) ⬇️
llmobs-anthropic 37.59% <8.00%> (-0.14%) ⬇️
llmobs-bedrock 36.82% <8.00%> (-0.12%) ⬇️
llmobs-google-genai 37.23% <8.00%> (-0.13%) ⬇️
llmobs-langchain 36.82% <8.00%> (-0.11%) ⬇️
llmobs-openai 40.89% <8.00%> (-0.14%) ⬇️
llmobs-sdk-active 45.61% <24.00%> (-0.14%) ⬇️
llmobs-sdk-latest 45.55% <24.00%> (-0.14%) ⬇️
llmobs-sdk-maintenance 45.61% <24.00%> (-0.14%) ⬇️
llmobs-sdk-oldest 45.60% <24.00%> (-0.14%) ⬇️
llmobs-vertex-ai 37.40% <8.00%> (-0.14%) ⬇️
openfeature-macos 38.44% <0.00%> (-0.03%) ⬇️
openfeature-ubuntu 38.52% <0.00%> (-0.03%) ⬇️
openfeature-unit-active 50.58% <ø> (-0.52%) ⬇️
openfeature-unit-latest 50.43% <ø> (-0.52%) ⬇️
openfeature-unit-maintenance 50.58% <ø> (-0.52%) ⬇️
openfeature-unit-oldest 50.58% <ø> (-0.52%) ⬇️
openfeature-windows 38.32% <0.00%> (-0.03%) ⬇️
platform-core 37.45% <ø> (ø)
platform-esbuild 40.80% <ø> (ø)
platform-instrumentations-misc 31.06% <0.00%> (-0.03%) ⬇️
platform-integration-active 47.62% <41.37%> (-0.02%) ⬇️
platform-integration-latest 47.58% <41.37%> (-0.02%) ⬇️
platform-integration-maintenance 47.64% <41.37%> (-0.02%) ⬇️
platform-integration-oldest 47.80% <41.37%> (-0.03%) ⬇️
platform-shimmer 42.68% <ø> (ø)
platform-unit-guardrails 36.55% <ø> (ø)
platform-webpack 20.61% <0.00%> (-0.02%) ⬇️
plugins-azure-durable-functions 37.41% <37.93%> (+0.16%) ⬆️
plugins-azure-event-hubs 35.23% <37.93%> (-0.02%) ⬇️
plugins-azure-service-bus 35.67% <37.93%> (-0.02%) ⬇️
plugins-bullmq 40.42% <68.00%> (-0.12%) ⬇️
plugins-cassandra 34.90% <8.00%> (-0.27%) ⬇️
plugins-cookie 26.91% <ø> (ø)
plugins-cookie-parser 26.71% <ø> (ø)
plugins-crypto 28.22% <ø> (ø)
plugins-dd-trace-api 35.11% <8.00%> (-0.14%) ⬇️
plugins-express-mongo-sanitize 26.85% <ø> (ø)
plugins-express-session 26.67% <ø> (ø)
plugins-fastify 39.04% <8.00%> (-0.14%) ⬇️
plugins-fetch 35.40% <22.66%> (-0.12%) ⬇️
plugins-fs 35.38% <8.00%> (-0.14%) ⬇️
plugins-generic-pool 25.83% <ø> (ø)
plugins-google-cloud-pubsub 42.81% <74.66%> (-0.08%) ⬇️
plugins-grpc 37.77% <22.66%> (-0.12%) ⬇️
plugins-handlebars 26.88% <ø> (ø)
plugins-hapi 36.97% <8.00%> (-0.14%) ⬇️
plugins-hono 37.25% <8.00%> (-0.14%) ⬇️
plugins-ioredis 35.44% <8.00%> (-0.14%) ⬇️
plugins-knex 26.55% <ø> (ø)
plugins-langgraph 34.78% <8.00%> (-0.14%) ⬇️
plugins-ldapjs 24.44% <ø> (?)
plugins-light-my-request 26.30% <ø> (ø)
plugins-limitd-client 29.83% <8.00%> (-0.13%) ⬇️
plugins-lodash 25.91% <ø> (ø)
plugins-mariadb 36.30% <8.00%> (-0.14%) ⬇️
plugins-memcached 35.09% <8.00%> (-0.14%) ⬇️
plugins-microgateway-core 36.07% <8.00%> (-0.14%) ⬇️
plugins-modelcontextprotocol-sdk 34.03% <8.00%> (-0.14%) ⬇️
plugins-moleculer 37.87% <24.00%> (-0.12%) ⬇️
plugins-mongodb 36.28% <8.00%> (-0.14%) ⬇️
plugins-mongodb-core 35.91% <8.00%> (-0.14%) ⬇️
plugins-mongoose 35.78% <8.00%> (-0.13%) ⬇️
plugins-multer 26.67% <ø> (ø)
plugins-mysql 36.16% <8.00%> (-0.14%) ⬇️
plugins-mysql2 36.14% <8.00%> (-0.14%) ⬇️
plugins-node-serialize 26.95% <ø> (ø)
plugins-opensearch 34.76% <8.00%> (-0.13%) ⬇️
plugins-passport-http 26.72% <ø> (ø)
plugins-pino 31.53% <8.00%> (-0.14%) ⬇️
plugins-postgres 34.21% <8.00%> (-0.13%) ⬇️
plugins-process 28.22% <ø> (ø)
plugins-pug 26.91% <ø> (ø)
plugins-redis 35.64% <8.00%> (-0.14%) ⬇️
plugins-router 39.45% <24.00%> (-0.13%) ⬇️
plugins-sequelize 25.61% <ø> (ø)
plugins-test-and-upstream-amqp10 35.41% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-amqplib 40.66% <74.66%> (-0.08%) ⬇️
plugins-test-and-upstream-apollo 36.25% <8.00%> (-0.13%) ⬇️
plugins-test-and-upstream-avsc 34.73% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-bunyan 30.94% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-connect 37.60% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-graphql 36.91% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-koa 37.23% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-protobufjs 34.94% <8.00%> (-0.14%) ⬇️
plugins-test-and-upstream-rhea 40.72% <74.66%> (-0.08%) ⬇️
plugins-undici 36.17% <22.66%> (-0.12%) ⬇️
plugins-url 28.22% <ø> (ø)
plugins-valkey 35.11% <8.00%> (-0.14%) ⬇️
plugins-vm 28.22% <ø> (ø)
plugins-winston 31.43% <8.00%> (-0.13%) ⬇️
plugins-ws 38.78% <24.00%> (?)
profiling-macos 43.40% <0.00%> (-0.10%) ⬇️
profiling-ubuntu 43.90% <0.00%> (-0.10%) ⬇️
profiling-windows 40.64% <0.00%> (-0.10%) ⬇️
serverless-aws-sdk-latest-aws-sdk 35.14% <22.66%> (-0.10%) ⬇️
serverless-aws-sdk-latest-bedrockruntime 33.56% <8.00%> (-0.12%) ⬇️
serverless-aws-sdk-latest-client 22.51% <ø> (ø)
serverless-aws-sdk-latest-dynamodb 35.95% <8.00%> (-0.13%) ⬇️
serverless-aws-sdk-latest-eventbridge 29.13% <6.89%> (-0.21%) ⬇️
serverless-aws-sdk-latest-kinesis 38.98% <73.33%> (-0.08%) ⬇️
serverless-aws-sdk-latest-lambda 36.28% <24.00%> (-0.11%) ⬇️
serverless-aws-sdk-latest-s3 34.15% <8.00%> (-0.12%) ⬇️
serverless-aws-sdk-latest-serverless-peer-service 40.44% <73.33%> (-0.08%) ⬇️
serverless-aws-sdk-latest-sns 40.15% <74.66%> (-0.07%) ⬇️
serverless-aws-sdk-latest-sqs 39.27% <74.66%> (-0.07%) ⬇️
serverless-aws-sdk-latest-stepfunctions 34.80% <22.66%> (-0.11%) ⬇️
serverless-aws-sdk-latest-util 47.80% <ø> (ø)
serverless-aws-sdk-oldest-aws-sdk 35.20% <22.66%> (-0.11%) ⬇️
serverless-aws-sdk-oldest-bedrockruntime 33.60% <8.00%> (-0.12%) ⬇️
serverless-aws-sdk-oldest-client 22.89% <ø> (ø)
serverless-aws-sdk-oldest-dynamodb 35.99% <8.00%> (-0.13%) ⬇️
serverless-aws-sdk-oldest-eventbridge 29.17% <6.89%> (-0.21%) ⬇️
serverless-aws-sdk-oldest-kinesis 39.06% <73.33%> (-0.08%) ⬇️
serverless-aws-sdk-oldest-lambda 36.33% <24.00%> (-0.11%) ⬇️
serverless-aws-sdk-oldest-s3 34.21% <8.00%> (-0.12%) ⬇️
serverless-aws-sdk-oldest-serverless-peer-service 40.51% <73.33%> (-0.08%) ⬇️
serverless-aws-sdk-oldest-sns 40.34% <74.66%> (-0.07%) ⬇️
serverless-aws-sdk-oldest-sqs 39.33% <74.66%> (-0.07%) ⬇️
serverless-aws-sdk-oldest-stepfunctions 34.85% <22.66%> (-0.11%) ⬇️
serverless-aws-sdk-oldest-util 48.12% <ø> (ø)
serverless-azure-functions-client 39.01% <41.37%> (-0.02%) ⬇️
serverless-azure-functions-eventhubs 38.67% <41.37%> (-0.02%) ⬇️
serverless-azure-functions-servicebus 38.73% <41.37%> (-0.02%) ⬇️
serverless-lambda 33.29% <8.00%> (-0.13%) ⬇️
test-optimization-cucumber-latest-7.0.0 50.47% <37.93%> (-0.02%) ⬇️
test-optimization-cucumber-latest-latest 53.15% <37.93%> (+0.10%) ⬆️
test-optimization-cucumber-oldest-7.0.0 50.49% <37.93%> (+0.10%) ⬆️
test-optimization-cypress-latest-12.0.0-commonJS 48.50% <0.00%> (+0.01%) ⬆️
test-optimization-cypress-latest-12.0.0-esm 48.56% <0.00%> (+0.06%) ⬆️
test-optimization-cypress-latest-14.5.4-commonJS 48.33% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-latest-14.5.4-esm 48.36% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-latest-latest-commonJS 48.86% <0.00%> (+0.09%) ⬆️
test-optimization-cypress-latest-latest-esm 48.85% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-oldest-12.0.0-commonJS 48.54% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-oldest-12.0.0-esm 48.57% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-oldest-14.5.4-commonJS 48.37% <0.00%> (+0.04%) ⬆️
test-optimization-cypress-oldest-14.5.4-esm 48.40% <0.00%> (+0.04%) ⬆️
test-optimization-jest-latest-latest 54.74% <37.93%> (+0.06%) ⬆️
test-optimization-jest-latest-oldest 53.90% <37.93%> (+0.16%) ⬆️
test-optimization-jest-oldest-latest 54.75% <37.93%> (+0.06%) ⬆️
test-optimization-jest-oldest-oldest 53.83% <37.93%> (+0.06%) ⬆️
test-optimization-mocha-latest-latest 53.24% <37.93%> (+0.06%) ⬆️
test-optimization-mocha-latest-oldest 50.80% <37.93%> (+0.06%) ⬆️
test-optimization-mocha-oldest-latest 53.37% <37.93%> (+0.06%) ⬆️
test-optimization-mocha-oldest-oldest 50.80% <37.93%> (+0.06%) ⬆️
test-optimization-playwright-latest-latest-playwright-active-test-span 44.25% <0.00%> (+0.26%) ⬆️
test-optimization-playwright-latest-latest-playwright-atr 42.99% <0.00%> (+0.08%) ⬆️
test-optimization-playwright-latest-latest-playwright-efd 43.27% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-latest-latest-playwright-impacted-tests 42.89% <0.00%> (-0.04%) ⬇️
test-optimization-playwright-latest-latest-playwright-reporting 43.01% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-latest-latest-playwright-test-management 45.02% <0.00%> (+0.07%) ⬆️
test-optimization-playwright-latest-oldest-playwright-active-test-span 44.29% <0.00%> (+0.26%) ⬆️
test-optimization-playwright-latest-oldest-playwright-atr 43.18% <0.00%> (+0.08%) ⬆️
test-optimization-playwright-latest-oldest-playwright-efd 43.30% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-latest-oldest-playwright-impacted-tests 42.93% <0.00%> (-0.04%) ⬇️
test-optimization-playwright-latest-oldest-playwright-reporting 43.06% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-latest-oldest-playwright-test-management 45.08% <0.00%> (+0.08%) ⬆️
test-optimization-playwright-oldest-latest-playwright-active-test-span 44.26% <0.00%> (+0.26%) ⬆️
test-optimization-playwright-oldest-latest-playwright-atr 43.03% <0.00%> (+0.08%) ⬆️
test-optimization-playwright-oldest-latest-playwright-efd 43.28% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-oldest-latest-playwright-impacted-tests 42.94% <0.00%> (-0.04%) ⬇️
test-optimization-playwright-oldest-latest-playwright-reporting 43.03% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-oldest-latest-playwright-test-management 45.04% <0.00%> (+0.07%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-active-test-span 44.33% <0.00%> (+0.26%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-atr 43.22% <0.00%> (+0.08%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-efd 43.31% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-impacted-tests 42.97% <0.00%> (-0.04%) ⬇️
test-optimization-playwright-oldest-oldest-playwright-reporting 43.08% <0.00%> (+0.06%) ⬆️
test-optimization-playwright-oldest-oldest-playwright-test-management 45.10% <0.00%> (+0.08%) ⬆️
test-optimization-selenium-latest 46.09% <37.93%> (+0.05%) ⬆️
test-optimization-selenium-oldest 45.59% <37.93%> (+0.06%) ⬆️
test-optimization-testopt-active 47.39% <37.93%> (+0.12%) ⬆️
test-optimization-testopt-latest 47.35% <37.93%> (+0.12%) ⬆️
test-optimization-testopt-maintenance 47.39% <37.93%> (+0.12%) ⬆️
test-optimization-testopt-oldest 48.20% <37.93%> (+0.13%) ⬆️
test-optimization-vitest-latest 51.44% <37.93%> (+0.06%) ⬆️
test-optimization-vitest-oldest 48.08% <37.93%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-prod-us1-4
Copy link
Copy Markdown

datadog-prod-us1-4 Bot commented May 1, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 97.44%
Overall Coverage: 86.43% (+0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 00d0ec6 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented May 1, 2026

Benchmarks

Benchmark execution time: 2026-05-05 13:06:28

Comparing candidate commit 00d0ec6 in PR branch BridgeAR/2026-05-01-pr8188-3-perf-propagation-dsm with baseline commit 4db54b1 in branch master.

Found 109 performance improvements and 0 performance regressions! Performance is the same for 1642 metrics, 93 unstable metrics.

scenario:datastreams-consume-18

  • 🟩 cpu_user_time [-499.059ms; -454.717ms] or [-13.848%; -12.618%]
  • 🟩 execution_time [-511.553ms; -467.065ms] or [-13.935%; -12.723%]
  • 🟩 instructions [-3.1G instructions; -3.0G instructions] or [-11.339%; -10.741%]

scenario:datastreams-consume-20

  • 🟩 cpu_user_time [-346.152ms; -300.879ms] or [-11.341%; -9.858%]
  • 🟩 execution_time [-357.744ms; -312.843ms] or [-11.520%; -10.074%]
  • 🟩 instructions [-2.2G instructions; -2.1G instructions] or [-9.805%; -9.225%]

scenario:datastreams-consume-22

  • 🟩 cpu_user_time [-291.075ms; -262.203ms] or [-10.423%; -9.389%]
  • 🟩 execution_time [-303.582ms; -273.106ms] or [-10.657%; -9.587%]
  • 🟩 instructions [-1.7G instructions; -1.6G instructions] or [-8.128%; -7.891%]

scenario:datastreams-consume-24

  • 🟩 cpu_user_time [-296.895ms; -274.466ms] or [-10.879%; -10.057%]
  • 🟩 execution_time [-312.102ms; -288.470ms] or [-11.192%; -10.345%]
  • 🟩 instructions [-1.8G instructions; -1.7G instructions] or [-8.806%; -8.674%]

scenario:datastreams-produce-18

  • 🟩 cpu_user_time [-3.769s; -3.721s] or [-57.497%; -56.766%]
  • 🟩 execution_time [-3.820s; -3.770s] or [-57.418%; -56.669%]
  • 🟩 instructions [-30.3G instructions; -30.2G instructions] or [-59.022%; -58.756%]

scenario:datastreams-produce-20

  • 🟩 cpu_user_time [-2.770s; -2.703s] or [-54.286%; -52.964%]
  • 🟩 execution_time [-2.806s; -2.737s] or [-54.195%; -52.865%]
  • 🟩 instructions [-21.0G instructions; -20.7G instructions] or [-54.843%; -53.960%]

scenario:datastreams-produce-22

  • 🟩 cpu_user_time [-2.073s; -2.036s] or [-48.003%; -47.135%]
  • 🟩 execution_time [-2.108s; -2.071s] or [-47.945%; -47.104%]
  • 🟩 instructions [-15.9G instructions; -15.8G instructions] or [-48.766%; -48.441%]

scenario:datastreams-produce-24

  • 🟩 cpu_user_time [-2.370s; -2.262s] or [-52.337%; -49.941%]
  • 🟩 execution_time [-2.408s; -2.299s] or [-52.212%; -49.866%]
  • 🟩 instructions [-16.4G instructions; -16.3G instructions] or [-49.845%; -49.777%]

scenario:datastreams-produce-high-cardinality-18

  • 🟩 cpu_user_time [-3.844s; -3.767s] or [-55.750%; -54.636%]
  • 🟩 execution_time [-3.861s; -3.782s] or [-55.383%; -54.245%]
  • 🟩 instructions [-30.0G instructions; -29.9G instructions] or [-57.680%; -57.349%]

scenario:datastreams-produce-high-cardinality-20

  • 🟩 cpu_user_time [-2.761s; -2.681s] or [-51.455%; -49.959%]
  • 🟩 execution_time [-2.773s; -2.691s] or [-51.044%; -49.534%]
  • 🟩 instructions [-20.8G instructions; -20.3G instructions] or [-53.332%; -52.220%]

scenario:datastreams-produce-high-cardinality-22

  • 🟩 cpu_user_time [-2.074s; -2.017s] or [-45.402%; -44.139%]
  • 🟩 execution_time [-2.088s; -2.027s] or [-45.018%; -43.698%]
  • 🟩 instructions [-15.6G instructions; -15.5G instructions] or [-47.331%; -46.912%]

scenario:datastreams-produce-high-cardinality-24

  • 🟩 cpu_user_time [-2.452s; -2.320s] or [-50.748%; -48.014%]
  • 🟩 execution_time [-2.484s; -2.352s] or [-50.467%; -47.783%]
  • 🟩 instructions [-16.0G instructions; -16.0G instructions] or [-48.025%; -47.942%]
  • 🟩 max_rss_usage [-36.052MB; -31.261MB] or [-25.544%; -22.149%]

scenario:datastreams-produce-manual-checkpoint-18

  • 🟩 cpu_user_time [-3.735s; -3.679s] or [-56.479%; -55.636%]
  • 🟩 execution_time [-3.774s; -3.718s] or [-56.259%; -55.425%]
  • 🟩 instructions [-29.9G instructions; -29.7G instructions] or [-57.841%; -57.587%]

scenario:datastreams-produce-manual-checkpoint-20

  • 🟩 cpu_user_time [-2.699s; -2.637s] or [-52.911%; -51.686%]
  • 🟩 execution_time [-2.730s; -2.665s] or [-52.719%; -51.455%]
  • 🟩 instructions [-20.8G instructions; -20.5G instructions] or [-53.767%; -52.919%]

scenario:datastreams-produce-manual-checkpoint-22

  • 🟩 cpu_user_time [-2.014s; -1.969s] or [-46.366%; -45.325%]
  • 🟩 execution_time [-2.038s; -1.993s] or [-46.116%; -45.081%]
  • 🟩 instructions [-15.6G instructions; -15.5G instructions] or [-47.402%; -46.990%]

scenario:datastreams-produce-manual-checkpoint-24

  • 🟩 cpu_user_time [-2.234s; -2.142s] or [-49.936%; -47.869%]
  • 🟩 execution_time [-2.262s; -2.166s] or [-49.687%; -47.594%]
  • 🟩 instructions [-16.0G instructions; -15.9G instructions] or [-48.248%; -48.178%]

scenario:datastreams-produce-with-message-size-18

  • 🟩 cpu_user_time [-6.659s; -6.599s] or [-65.799%; -65.205%]
  • 🟩 execution_time [-6.726s; -6.665s] or [-65.725%; -65.130%]
  • 🟩 instructions [-53.2G instructions; -53.0G instructions] or [-66.265%; -66.057%]

scenario:datastreams-produce-with-message-size-20

  • 🟩 cpu_user_time [-4.589s; -4.518s] or [-62.346%; -61.380%]
  • 🟩 execution_time [-4.635s; -4.562s] or [-62.258%; -61.275%]
  • 🟩 instructions [-35.3G instructions; -35.0G instructions] or [-62.699%; -62.162%]

scenario:datastreams-produce-with-message-size-22

  • 🟩 cpu_user_time [-3.044s; -3.004s] or [-52.476%; -51.782%]
  • 🟩 execution_time [-3.091s; -3.047s] or [-52.485%; -51.741%]
  • 🟩 instructions [-23.9G instructions; -23.8G instructions] or [-53.183%; -52.962%]

scenario:datastreams-produce-with-message-size-24

  • 🟩 cpu_user_time [-3.703s; -3.567s] or [-57.713%; -55.599%]
  • 🟩 execution_time [-3.751s; -3.616s] or [-57.626%; -55.560%]
  • 🟩 instructions [-26.1G instructions; -26.1G instructions] or [-54.639%; -54.590%]

scenario:propagation-extract-18

  • 🟩 cpu_user_time [-208.939ms; -191.951ms] or [-8.328%; -7.651%]
  • 🟩 execution_time [-209.943ms; -193.307ms] or [-8.208%; -7.558%]
  • 🟩 instructions [-1.6G instructions; -1.5G instructions] or [-8.919%; -8.651%]

scenario:propagation-extract-20

  • 🟩 cpu_user_time [-243.940ms; -224.102ms] or [-10.017%; -9.203%]
  • 🟩 execution_time [-243.651ms; -224.526ms] or [-9.825%; -9.054%]
  • 🟩 instructions [-1.8G instructions; -1.7G instructions] or [-10.193%; -9.860%]

scenario:propagation-extract-22

  • 🟩 cpu_user_time [-223.284ms; -205.544ms] or [-9.687%; -8.917%]
  • 🟩 execution_time [-223.488ms; -205.975ms] or [-9.502%; -8.758%]
  • 🟩 instructions [-1.8G instructions; -1.7G instructions] or [-10.266%; -10.014%]

scenario:propagation-extract-24

  • 🟩 cpu_user_time [-218.692ms; -180.813ms] or [-8.920%; -7.375%]
  • 🟩 execution_time [-216.886ms; -179.849ms] or [-8.613%; -7.142%]
  • 🟩 instructions [-1.5G instructions; -1.5G instructions] or [-8.656%; -8.484%]

scenario:propagation-extract-baggage-ascii-18

  • 🟩 cpu_user_time [-201.626ms; -184.145ms] or [-8.063%; -7.363%]
  • 🟩 execution_time [-203.019ms; -185.679ms] or [-7.968%; -7.287%]
  • 🟩 instructions [-1.6G instructions; -1.5G instructions] or [-8.711%; -8.396%]

scenario:propagation-extract-baggage-ascii-20

  • 🟩 cpu_user_time [-246.255ms; -224.109ms] or [-10.053%; -9.149%]
  • 🟩 execution_time [-247.239ms; -225.780ms] or [-9.915%; -9.055%]
  • 🟩 instructions [-1.8G instructions; -1.7G instructions] or [-10.075%; -9.761%]

scenario:propagation-extract-baggage-ascii-22

  • 🟩 cpu_user_time [-230.509ms; -212.636ms] or [-9.980%; -9.206%]
  • 🟩 execution_time [-229.897ms; -212.876ms] or [-9.753%; -9.031%]
  • 🟩 instructions [-1.7G instructions; -1.7G instructions] or [-10.231%; -9.975%]

scenario:propagation-extract-baggage-ascii-24

  • 🟩 cpu_user_time [-227.537ms; -191.345ms] or [-9.291%; -7.813%]
  • 🟩 execution_time [-223.650ms; -188.499ms] or [-8.899%; -7.500%]
  • 🟩 instructions [-1.6G instructions; -1.5G instructions] or [-8.719%; -8.528%]

scenario:propagation-extract-inject-18

  • 🟩 cpu_user_time [-451.567ms; -422.996ms] or [-8.277%; -7.753%]
  • 🟩 execution_time [-451.323ms; -424.289ms] or [-8.180%; -7.690%]
  • 🟩 instructions [-2.9G instructions; -2.9G instructions] or [-8.020%; -7.863%]

scenario:propagation-extract-inject-20

  • 🟩 cpu_user_time [-411.127ms; -384.101ms] or [-7.961%; -7.438%]
  • 🟩 execution_time [-411.596ms; -386.230ms] or [-7.879%; -7.393%]
  • 🟩 instructions [-3.0G instructions; -2.9G instructions] or [-8.429%; -8.281%]

scenario:propagation-extract-inject-22

  • 🟩 cpu_user_time [-397.241ms; -363.918ms] or [-7.828%; -7.171%]
  • 🟩 execution_time [-396.168ms; -363.507ms] or [-7.718%; -7.081%]
  • 🟩 instructions [-2.9G instructions; -2.9G instructions] or [-8.449%; -8.325%]

scenario:propagation-extract-inject-24

  • 🟩 cpu_user_time [-382.750ms; -317.365ms] or [-7.464%; -6.189%]
  • 🟩 execution_time [-383.526ms; -319.243ms] or [-7.365%; -6.130%]
  • 🟩 instructions [-2.6G instructions; -2.6G instructions] or [-7.476%; -7.342%]

scenario:propagation-inject-18

  • 🟩 cpu_user_time [-240.322ms; -229.909ms] or [-9.340%; -8.935%]
  • 🟩 execution_time [-240.412ms; -231.196ms] or [-9.214%; -8.861%]
  • 🟩 instructions [-1.6G instructions; -1.6G instructions] or [-9.762%; -9.668%]

scenario:propagation-inject-20

  • 🟩 cpu_user_time [-199.869ms; -187.795ms] or [-8.191%; -7.697%]
  • 🟩 execution_time [-200.143ms; -187.832ms] or [-8.132%; -7.631%]
  • 🟩 instructions [-1.5G instructions; -1.4G instructions] or [-9.102%; -8.875%]

scenario:propagation-inject-22

  • 🟩 cpu_user_time [-191.236ms; -178.374ms] or [-7.925%; -7.392%]
  • 🟩 execution_time [-189.845ms; -177.894ms] or [-7.787%; -7.296%]
  • 🟩 instructions [-1.5G instructions; -1.4G instructions] or [-9.059%; -8.912%]

scenario:propagation-inject-24

  • 🟩 cpu_user_time [-188.612ms; -172.518ms] or [-7.788%; -7.124%]
  • 🟩 execution_time [-186.225ms; -170.957ms] or [-7.605%; -6.982%]
  • 🟩 instructions [-1.3G instructions; -1.2G instructions] or [-7.958%; -7.871%]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Overall package size

Self size: 5.71 MB
Deduped: 6.55 MB
No deduping: 6.55 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.1 | 82.56 kB | 817.39 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

BridgeAR added 2 commits May 5, 2026 11:15
W3C baggage extract and `_dd.p.*` tag inject both run on every
traced HTTP request. Several sub-allocations are dropped:

`text_map.js` swaps three single-char-class `replaceAll(/[\xNN]/g, ...)`
regex literals for `replaceAll('=', '~')` / `replaceAll('~', '=')`,
which skip the regex match path. `_injectTags` and
`_injectTraceparent` walk `trace.tags` via `Object.keys(...)`
instead of banned `for-in`; the trace-tags object's prototype
chain isn't ours to trust, and `for-in` enumerates inherited
keys. `_injectBaggageItems` swaps `Object.entries` for
`Object.keys` + indexed read, dropping the per-baggage-item
`[k, v]` tuple. `_extractBaggageItems` caches the `baggageTagKeys`
`Set` on the propagator (rebuilt only when the config array
reference changes, e.g. remote-config rotation) and gates
`decodeURIComponent` behind `value.includes('%')` — a
microbenchmark pins the gated path at 13.4x faster than running
`decodeURIComponent` on plain ASCII baggage and only 2% slower
than the raw call on percent-encoded values.

`tracestate.js#forVendor` reuses the `state.toString()` value
computed one line above instead of recomputing it.

The original draft also rewrote `tracestate#fromString` to drop
an `Array#unshift` quadratic; #8256 landed a linear parser first
that supersedes those hunks, so they're dropped.
DSM observes every Kafka, SQS, SNS, Kinesis, Pub/Sub, and AMQP
message when enabled, so the per-checkpoint hot path compounds.
Several allocations are removed without changing the wire format:

1. `getSizeOrZero` stopped allocating a fresh Buffer copy of every
   string just to read its UTF-8 byte length. `Buffer.byteLength`
   returns the same value with no allocation. `getHeadersSize`'s
   `Object.entries(...).reduce(...)` becomes a `for (const key of
   Object.keys(headers))` loop, dropping the per-header `[k, v]`
   tuple and the reducer closure.
2. `pathway.js#shaHash` extracted the first 8 bytes of SHA-256 by
   round-tripping through a 64-char hex string + a 16-char slice +
   a hex-decoded Buffer. `digest().subarray(0, 8)` produces the same
   bytes directly. `computeHash` now also caches
   `hashableEdgeTags.join('')` and `propagationHashBigInt.toString(16)`
   once per call (each was computed twice), gates the
   `manual_checkpoint:true` filter on `includes(...)` so the common
   path skips the alloc, and reuses a module-scope 20-byte scratch
   buffer to assemble `encodePathwayContext` with a single
   `Buffer.from(subarray)` copy-out instead of seven nested allocs.
3. `setCheckpoint` precomputes `PATHWAY_HEADER_BYTES` from the static
   header overhead instead of allocating a temp object, encoding
   it, and JSON-stringifying just to read its length. It now reads
   the direction from `edgeTags[0]` directly: every in-tree caller
   places it there, the `DataStreamsCheckpointer` shape is updated
   to match, and the test fixture pinning that arg order is updated
   in the same commit.

Drive-by fix:

* `recordCheckpoint` reuses the `BigInt` already computed by the
  `StatsPoint` returned from `forCheckpoint(...)` instead of running
  `readBigUInt64LE` a second time. `setCheckpoint` returns
  `undefined` (rather than `null`) on the disabled fast path so
  the function shape matches the rest of the file.
* `processor.js` drops the `DsmPathwayCodec` import that the
  inlined byte-count made unreachable; `pathway.js` exports
  `CONTEXT_PROPAGATION_KEY_BASE64` so the constant calculation is
  anchored to the actual header key.
* `encoding.js` adds an `encodeVarintInto(target, offset, value)`
  helper so the pathway encoder can write directly into the scratch
  buffer instead of allocating a per-varint `Uint8Array` and
  copying.
@BridgeAR BridgeAR force-pushed the BridgeAR/2026-05-01-pr8188-3-perf-propagation-dsm branch from 00b73c3 to 00d0ec6 Compare May 5, 2026 09:29
@BridgeAR BridgeAR marked this pull request as ready for review May 5, 2026 12:46
@BridgeAR BridgeAR requested review from a team as code owners May 5, 2026 12:46
@BridgeAR BridgeAR requested review from khanayan123 and removed request for a team May 5, 2026 12:46
@BridgeAR BridgeAR merged commit 6500302 into master May 5, 2026
1128 of 1133 checks passed
@BridgeAR BridgeAR deleted the BridgeAR/2026-05-01-pr8188-3-perf-propagation-dsm branch May 5, 2026 16:02
@dd-octo-sts dd-octo-sts Bot mentioned this pull request May 6, 2026
sabrenner pushed a commit that referenced this pull request May 6, 2026
…8234)

* perf(propagation): tighten baggage and tag inject paths

W3C baggage extract and `_dd.p.*` tag inject both run on every
traced HTTP request. Several sub-allocations are dropped:

`text_map.js` swaps three single-char-class `replaceAll(/[\xNN]/g, ...)`
regex literals for `replaceAll('=', '~')` / `replaceAll('~', '=')`,
which skip the regex match path. `_injectTags` and
`_injectTraceparent` walk `trace.tags` via `Object.keys(...)`
instead of banned `for-in`; the trace-tags object's prototype
chain isn't ours to trust, and `for-in` enumerates inherited
keys. `_injectBaggageItems` swaps `Object.entries` for
`Object.keys` + indexed read, dropping the per-baggage-item
`[k, v]` tuple. `_extractBaggageItems` caches the `baggageTagKeys`
`Set` on the propagator (rebuilt only when the config array
reference changes, e.g. remote-config rotation) and gates
`decodeURIComponent` behind `value.includes('%')` — a
microbenchmark pins the gated path at 13.4x faster than running
`decodeURIComponent` on plain ASCII baggage and only 2% slower
than the raw call on percent-encoded values.

`tracestate.js#forVendor` reuses the `state.toString()` value
computed one line above instead of recomputing it.

The original draft also rewrote `tracestate#fromString` to drop
an `Array#unshift` quadratic; #8256 landed a linear parser first
that supersedes those hunks, so they're dropped.

* perf(dsm): trim per-checkpoint and per-message allocations

DSM observes every Kafka, SQS, SNS, Kinesis, Pub/Sub, and AMQP
message when enabled, so the per-checkpoint hot path compounds.
Several allocations are removed without changing the wire format:

1. `getSizeOrZero` stopped allocating a fresh Buffer copy of every
   string just to read its UTF-8 byte length. `Buffer.byteLength`
   returns the same value with no allocation. `getHeadersSize`'s
   `Object.entries(...).reduce(...)` becomes a `for (const key of
   Object.keys(headers))` loop, dropping the per-header `[k, v]`
   tuple and the reducer closure.
2. `pathway.js#shaHash` extracted the first 8 bytes of SHA-256 by
   round-tripping through a 64-char hex string + a 16-char slice +
   a hex-decoded Buffer. `digest().subarray(0, 8)` produces the same
   bytes directly. `computeHash` now also caches
   `hashableEdgeTags.join('')` and `propagationHashBigInt.toString(16)`
   once per call (each was computed twice), gates the
   `manual_checkpoint:true` filter on `includes(...)` so the common
   path skips the alloc, and reuses a module-scope 20-byte scratch
   buffer to assemble `encodePathwayContext` with a single
   `Buffer.from(subarray)` copy-out instead of seven nested allocs.
3. `setCheckpoint` precomputes `PATHWAY_HEADER_BYTES` from the static
   header overhead instead of allocating a temp object, encoding
   it, and JSON-stringifying just to read its length. It now reads
   the direction from `edgeTags[0]` directly: every in-tree caller
   places it there, the `DataStreamsCheckpointer` shape is updated
   to match, and the test fixture pinning that arg order is updated
   in the same commit.

Drive-by fix:

* `recordCheckpoint` reuses the `BigInt` already computed by the
  `StatsPoint` returned from `forCheckpoint(...)` instead of running
  `readBigUInt64LE` a second time. `setCheckpoint` returns
  `undefined` (rather than `null`) on the disabled fast path so
  the function shape matches the rest of the file.
* `processor.js` drops the `DsmPathwayCodec` import that the
  inlined byte-count made unreachable; `pathway.js` exports
  `CONTEXT_PROPAGATION_KEY_BASE64` so the constant calculation is
  anchored to the actual header key.
* `encoding.js` adds an `encodeVarintInto(target, offset, value)`
  helper so the pathway encoder can write directly into the scratch
  buffer instead of allocating a per-varint `Uint8Array` and
  copying.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants